package com.shop.cereshop.agent.exception;


import com.shop.cereshop.commons.constant.CoReturnFormat;

/**
 * 功能描述：业务异常类
 *
 * @Author: zdd
 * @Date: 2020/4/19 16:12
 */
public class BusinessException extends RuntimeException {

    private String code;

    public BusinessException() {
        super();
        this.code = CoReturnFormat.FAIL;
    }

    public BusinessException(String message) {
        super(message);
        this.code = CoReturnFormat.FAIL;
    }

    public BusinessException(String code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
        this.code = CoReturnFormat.FAIL;
    }

    public BusinessException(String code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    /**
     * 快速创建业务异常
     */
    public static BusinessException of(String message) {
        return new BusinessException(message);
    }

    /**
     * 快速创建业务异常
     */
    public static BusinessException of(String code, String message) {
        return new BusinessException(code, message);
    }
} 